import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/31 14:17
 */

public class Solution {
    public String convert(String s, int numRows) {
        //处理一下边界情况
        if (numRows == 1) return s;

        int d = 2 * numRows - 2, n = s.length();
        StringBuilder ret = new StringBuilder();

        //1.处理第一行
        for (int i = 0; i < n; i += d)
            ret.append(s.charAt(i));

        //2.处理中间行
        for (int k = 1; k < numRows - 1; k++) {//一次枚举中间行
            for (int i = k, j = d - i; i < n || j < n; i += d, j += d) {
                if (i < n) ret.append(s.charAt(i));
                if (j < n) ret.append(s.charAt(j));
            }
        }

        //3.处理最后一行
        for (int i = numRows - 1; i < n; i += d) {
            ret.append(s.charAt(i));
        }

        return ret.toString();
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.nextLine();
            int numRow = in.nextInt();
            in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.convert(s, numRow));
        }
    }
}